package com.cskaoyan.wordmemorize.controller.app;

import com.cskaoyan.wordmemorize.auth.StpKit;
import com.cskaoyan.wordmemorize.common.result.Result;
import com.cskaoyan.wordmemorize.dto.admin.UserVocAISituationDTO;
import com.cskaoyan.wordmemorize.dto.app.AIReviewReadDTO;
import com.cskaoyan.wordmemorize.request.AIReviewReadCommand;
import com.cskaoyan.wordmemorize.service.UserPrivilegeService;
import com.cskaoyan.wordmemorize.service.UserService;
import com.cskaoyan.wordmemorize.service.impl.UserPrivilegeServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/user/priviledge/review/ai/read")
public class UserAIReadController {
    @Autowired
    UserPrivilegeService userPrivilegeService;
    @Autowired
    UserService userService;

    @Autowired
    UserPrivilegeServiceImpl userPrivilegeServiceImpl;


    @PostMapping((""))
    public Result<List<AIReviewReadDTO>> userAIRead(@RequestBody AIReviewReadCommand command) {
        Long userId = StpKit.USER.getLoginIdAsLong();
        List<AIReviewReadDTO> content = userPrivilegeService.getAIReviewReadContent(command, userId);
        return Result.ok(content);
    }

    @PostMapping("/options")
    public Result<List<UserVocAISituationDTO>> userGetAISituation() {
        return Result.ok(userPrivilegeService.getAIReviewReadOptions());
    }

    @PostMapping("/free")
    public Result<Integer> userGetAIReadFreeCount() {
        Long userId = StpKit.USER.getLoginIdAsLong();

        Integer count = userPrivilegeServiceImpl.getUserVocAIReadRemainFreeCount(userId);
        return Result.ok(count);

    }


}
